
layui.use(['form','element','jquery','layer'], function(){
	var $=layui.jquery,form=layui.form;
		//追加配件类型option
		partstypeinfo();
		//追加汽车类型到option
		cardtypeinfo();
	/*
	 * 
	 * ajax添加
$('.inventoryinfoBut').on('click',function () {
	var ctitype=$(".cardtypeinfoName option:checked").val();
	var pTITypeName=$(".pTITypeName option:checked").val();
	var iTIName=$(".iTIName").val();
	var iTIPrice=$(".iTIPrice").val();
	var iTISelling=$(".iTISelling").val();
	var iTIPicture=$(".iTIPicture").val();
	var iTIParameter=$(".iTIParameter").val();
	var iTIEffect=$(".iTIEffect").val();
	var iTICount=$(".iTICount").val();
	var file=$('.iTIPicture').files[0];
	console.log(file);
	if(iTIName=="" || iTIPrice=="" || iTISelling=="" || iTIPicture=="" || iTIParameter=="" || iTIEffect=="" || iTICount==""){
		return;
	}
	$.ajax({
			type:"post",
			url:"inventoryinfoAction!save",
			async:false,
			data:{"partstypeinfo.ptiid":pTITypeName,"cardtypeinfo.ctiid":ctitype,"inventoryinfo.itiname":iTIName,"inventoryinfo.itiprice":iTIPrice,"inventoryinfo.itiselling":iTISelling,"inventoryinfo.itipicture":iTIPicture,"inventoryinfo.itiparameter":iTIParameter,"inventoryinfo.itieffect":iTIEffect,"inventoryinfo.iticount":iTICount,"upload":file},
			success:function(){
				alert("添加成功！");
				//parent.location.reload();
			}
		});
})
*/

function partstypeinfo(){
	//追加配件类型option
	$.ajax({
		type:"post",
		url:"partstypeinfoAction!findAll",
		async:false,
		data:{"nowTime":new Date()},
		dataType:"json",
		success:function(msg){
			//追加
			$(msg).each(function(i){
				$(".pTITypeName").append("<option value="+msg[i].ptiid+">"+msg[i].ptitypeName+"</option>");
			})
			form.render('select');
		}
	});
}

function cardtypeinfo(){
	//追加汽车类型option
	$.ajax({
		type:"post",
		url:"cardtypeinfoAction!findAll",
		async:false,
		data:{"nowTime":new Date()},
		dataType:"json",
		success:function(msg){
			//追加
			$(msg).each(function(i){
				$(".cardtypeinfoName").append("<option value="+msg[i].ctiid+">"+msg[i].ctitype+"</option>");
			})
			form.render('select');
		}
	});
}
})